package com.dingpeikeji.quickdeer.modules.rentproduct.service;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.dingpeikeji.quickdeer.core.common.persistence.Page;
import com.dingpeikeji.quickdeer.core.common.service.CrudService;
import com.dingpeikeji.quickdeer.core.modules.sys.utils.UserUtils;
import com.dingpeikeji.quickdeer.modules.rentproduct.dao.OfficeSaveDao;
import com.dingpeikeji.quickdeer.modules.rentproduct.entity.OfficeSave;

/**
 * 到账登记Service
 * @author wuh
 * @version 2016-08-30
 */
@Service
@Transactional(readOnly = true)
public class OfficeSaveService extends CrudService<OfficeSaveDao, OfficeSave> {

	public OfficeSave get(String reserveid) {
		return super.get(reserveid);
	}
	
	public List<OfficeSave> findList(OfficeSave officeSave) {
		return super.findList(officeSave);
	}
	
	public Page<OfficeSave> findPage(Page<OfficeSave> page, OfficeSave officeSave) {
		return super.findPage(page, officeSave);
	}
	
	@Transactional(readOnly = false)
	public void save(OfficeSave officeSave) {
		if(StringUtils.isEmpty(officeSave.getReserveid())){
			officeSave.setCreateBy(UserUtils.getUser());
			officeSave.setCreateDate(new Date());
			dao.insert(officeSave);
		}else{
			dao.update(officeSave);
		}
	}
	
	@Transactional(readOnly = false)
	public void delete(OfficeSave officeSave) {
		super.delete(officeSave);
	}
	
}